﻿namespace TaskPollingWebApi.Models
{
    /// <summary>
    /// 任务状态枚举
    /// </summary>
    public enum TaskState
    {
        Pending,    // 等待中
        Running,    // 运行中
        Completed,  // 已完成
        Failed,     // 失败
        Timeout     // 超时
    }

    /// <summary>
    /// 任务信息模型
    /// </summary>
    public class TaskInfo
    {
        public int Id { get; set; }
        public string Name { get; set; } = string.Empty;
        public TaskState State { get; set; } = TaskState.Pending;
        public string? Result { get; set; }
        public DateTime LastChecked { get; set; }
        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
        public int CheckCount { get; set; } = 0;
    }

    /// <summary>
    /// 轮询状态信息
    /// </summary>
    public class PollingStatus
    {
        public bool IsRunning { get; set; }
        public bool IsPollingInProgress { get; set; }
        public int CompletedCycles { get; set; }
        public int TotalTasks { get; set; }
        public DateTime? LastCycleStartTime { get; set; }
        public DateTime? LastCycleEndTime { get; set; }
        public TimeSpan? LastCycleDuration { get; set; }
    }

}
